﻿using GoodsModule.Application.Commands;
using GoodsModule.Application.Queries;
using MediatR;
using Microsoft.AspNetCore.Mvc;

namespace GoodsModule.Host.WebAPI.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public partial class GoodsController(IMediator _mediator) : ControllerBase
    {

        [HttpGet]
        public async Task<List<Domain.GoodsAggregate.Goods>> GetList([FromQuery] GoodsGetListReq query)
        {
            return await _mediator.Send(query, HttpContext.RequestAborted);
        }

        [HttpPost]
        public async Task<Domain.GoodsAggregate.Goods> Create(CreateGoodsCommand command)
        {
            return await _mediator.Send(command, HttpContext.RequestAborted);
        }

        [HttpPut]
        public async Task<Domain.GoodsAggregate.Goods> Change(ChangeGoodsCommand command)
        {
            return await _mediator.Send(command, HttpContext.RequestAborted);
        }

        [HttpPost]
        public async Task<List<Domain.GoodsAggregate.GoodsImage>> SetGoodsImages(SetGoodsImagesCommand command)
        {
            return await _mediator.Send(command, HttpContext.RequestAborted);
        }

    }
}
